package public

import (
	"server/game/cache"
	"server/game/model"

	"github.com/hwcer/cosgo/registry"
	"github.com/hwcer/yyds/context"
)

func init() {
	Register(&draw{})
}

// 抽卡 协议兼容模式 后续使用 系统自带 /gacha/* 相关
type draw struct {
}

func (this *draw) Caller(node *registry.Node, handle *context.Context) interface{} {
	f := node.Method().(func(*draw, *context.Context) interface{})
	return f(this, handle)
}

/**
 * @name submit
 * @param int id 卡池id
 * @param int num 次数
 * 抽卡
 */

func (this *draw) Submit(c *context.Context) interface{} {
	c.Player.Add(60700000, 1)
	c.Player.Add(20009042, 1)
	role := cache.GetRole(c.Player.Updater)
	role.Set("TotalDrawNum", 1)
	role.Set("DrawPool", map[int32]int32{4: 1})
	DrawList := model.DrawList{}
	DrawList[4] = &model.Draw{
		DrawTime: 0,
		AddPoint: 0,
	}
	role.Set("Draw", DrawList)
	return "抽卡请使用 gacha 相关接口"
}

//单抽统一接口
//每一抽都是基于上一抽的数据
//参数 卡池ID  卡池数据  本次抽卡是否需要保底2星

func (this *draw) DrawReward(c *context.Context) interface{} {
	c.Player.Add(60700000, 1)
	c.Player.Add(20009042, 1)
	role := cache.GetRole(c.Player.Updater)
	role.Set("TotalDrawNum", 1)
	role.Set("DrawPool", map[int32]int32{4: 1})
	DrawList := model.DrawList{}
	DrawList[4] = &model.Draw{
		DrawTime: 0,
		AddPoint: 0,
	}
	role.Set("Draw", DrawList)
	return "抽卡请使用 gacha 相关接口"
}

/**
 * @name getDrawRecordListFromRedis
 * @param string id 玩家uid
 * @param int drawType 卡池类型
 * 获取抽卡记录
 */

/*
public partial struct drawRecordData

	{
	    /// 单位获得时间
	    public long unitGetTime;
	    /// 单位Id
	    public int unitID;
	}
*/
func (this *draw) getDrawRecordListFromRedis(c *context.Context) interface{} {
	return nil
}
